{include file="admintemplate/header.htm"}
<script src="./public/js/containspecial.js"></script>
<div class="title">添加新栏目</div>
<div class="div_form">
		<div class="cont">
			<div class="uinArea">
                <label class="input-tips">栏目名:</label>
                <input type="text" id="column_name" name="column_name" class="inputOuter"/>
                <span class="err_msg" id="tips-name"></span>
            </div>
            <div class="uinArea">
                <label class="input-tips">父栏目:</label>
                <select id="column_pid" class="inputOuter" style="height:38px;">
                   <option value="0" selected="true">顶层栏目</option>
                     {foreach $columnlist as $column}
                       <option value="{$column.column_id}">{$column.column_name}</option>
                     {/foreach}
                </select>
                <span class="err_msg" id="tips-pid"></span>
            </div>
            <div class="all_btn">
               <button id="add" class="button_blue" style="width:180px;height:50px;">添&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;加</button>
            </div>
	   </div>
</div>
<script>
{literal}
    $("#add").click(function(){
        if($("#column_name").val() == ""){
            $("#tips-name").html("栏目名不能为空！");
            return false;
        }else if($("#column_name").val().length > 20){
            $("#tips-name").html("栏目名长度不能大于20！");
            return false;
        }else if(containSpecial($("#column_name").val())){
            $("#tips-name").html("栏目名不能包含特殊字符");
            return false;
        }else{
            $("#tips-name").html("");
        }
        
        data = {
            "mod":"column",
            "act":"add",
            "column_pid":$("#column_pid").val(),
            "column_name":$("#column_name").val()
        };
        $.get("index.php",data,function(rtn){
            if($.trim(rtn) == "ok"){
                alertify.success("添加栏目成功！");
                location.href = "index.php?mod=column&act=index";
            }else{
                alertify.error("添加栏目失败！");
            }
        });
    });
{/literal}
</script>
{include file="admintemplate/footer.htm"}